<%@ page import="com.interfaces.SysLogController" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户操作日志</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <%
        String path = request.getContextPath();
        path = "/".equals(path)?"":path;
        request.setAttribute("path", path);
    %>
    <script type="text/javascript">
        var path = "${path}";
    </script>

    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="${path}/public/adminlte/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="${path}/public/font-awesome-4.7.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="${path}/public/ionicons/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="${path}/public/adminlte/plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="${path}/public/adminlte/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
          page. However, you can choose any other skin. Make sure you
          apply the skin class to the body tag so the changes take effect.
    -->
    <link rel="stylesheet" href="${path}/public/adminlte/dist/css/skins/_all-skins.min.css">

    <link rel="stylesheet" href="${path}/css/common.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to get the
desired effect
|---------------------------------------------------------|
| SKINS         | skin-blue                               |
|               | skin-black                              |
|               | skin-purple                             |
|               | skin-yellow                             |
|               | skin-red                                |
|               | skin-green                              |
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed                                   |
|               | layout-boxed                            |
|               | layout-top-nav                          |
|               | sidebar-collapse                        |
|               | sidebar-mini                            |
|---------------------------------------------------------|
-->
<body >
<div class="container">

            <div class="box box-primary">
                <!-- /.box-header -->
                <div class="box-body">
                <!-- 
                    <div class="row">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label for="name">用户名</label>
                                <input type="text" class="form-control" id="name">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label for="phone">电话</label>
                                <input type="text" class="form-control" id="phone">
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label for="fullName">姓名</label>
                                <input type="text" class="form-control" id="fullName">
                            </div>
                        </div>
                        <div class="col-md-3">
                        </div>
                    </div>
                     -->
                    <div class="row">
                        <div class="col-md-12">
                            <button type="submit" id="btnSearch" class="btn btn-primary pull-right" style="display:none;">刷新</button> 
                            <button type="submit" id="btnSearch1" class="btn btn-primary pull-right" style="margin-right:10px;">搜 索</button>
                            <input type="hidden" id="curid" value="">
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.box -->
            <div class="box box-primary">
                <!-- /.box-header -->
                <div class="box-body">
                    <table id="dg" class="table table-bordered table-hover">
                    
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
</div>

<!-- ./wrapper -->

<div class="modal fade" id="modelContainer" role="basic" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 2.2.3 -->
<script src="${path}/public/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="${path}/public/adminlte/bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="${path}/public/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${path}/public/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="${path}/public/adminlte/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="${path}/public/adminlte/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="${path}/public/adminlte/dist/js/app.min.js"></script>
<script src="${path}/js/sysDict.js"></script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. Slimscroll is required when using the
     fixed layout. -->
<!-- page script -->
<script>
	var table;
	var url = window.location.search;
	var arr=url.split('&');
	var curid = "tab_"+arr[arr.length-2];
	$('#curid').val(curid);
    $(function () {
        table = $('#dg').DataTable({
       		"paging": true,
            "lengthChange": true,
            "searching": false,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "processing":true,//显示处理中
        	"serverSide":true,//每次都请求服务器，包括搜索、切换每页显示数、翻页
        	"stateSave": true,//刷新时保持翻页状态，table.fnDraw(false);//刷新保持分页状态
        	"pageLength": 10,  //首次加载的数据条数
        	//"searchDelay":1000,
           "ajax": {
               "url": "${path}<%=SysLogController.URL_MAIN_SEARCH%>?&"+arr[arr.length-1],
               //"dataSrc": "data",//默认为data
               "dataSrc": "data",
               //"delay": "1000",
               "type": "post",
               "error":function(){
               //alert("");
               },
              // "success":function(){
               //}
           },
           "columns": [
               { "data": "id", "title":"ID","defaultContent":""},
               { "data": "user_name", "title":"用户","defaultContent":""},
               { "data": "privilege_comments", "title":"功能说明","defaultContent":""},
               { "data": "add_time", "title":"时间","defaultContent":""},
               { "data": "issuccess", "title":"是否成功","defaultContent":""}
           ],
            "columnDefs": [
                  {
                  	  "targets": [4],
                      "data": "issuccess",
                      "render": function(data, type, full) { 
                      return data==0?"失败":"成功";
                      }
                  }
              ],
           "language": {
               "sProcessing": "处理中...",
               "sLengthMenu": "显示 _MENU_ 项结果",
               "sZeroRecords": "没有匹配结果",
               "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
               "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
               "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
               "sInfoPostFix": "",
               "sSearch": "搜索:",
               "sUrl": "",
               "sEmptyTable": "表中数据为空",
               "sLoadingRecords": "载入中...",
               "sInfoThousands": ",",
               "oPaginate": {
                   "sFirst": "首页",
                   "sPrevious": "上页",
                   "sNext": "下页",
                   "sLast": "末页"
               },
               "oAria": {
                   "sSortAscending": ": 以升序排列此列",
                   "sSortDescending": ": 以降序排列此列"
               }
           }
       });
       //刷新，保持之前的搜索条件不变，用于新增或修改后刷新该列表
		$("#btnSearch").click(function () {
			 //table.ajax.reload();//刷新回到首页
			 table.draw( false );//保持分页状态刷新
		});
        
        //重新按修改后的搜索条件进行搜索
        $("#btnSearch1").click(function () {
        //每次点击搜索，都重新将搜索条件加载给table，且查询结果从第一页开始
        	var param = {
		        //"name": $('#name').val(),
		        //"phome": $('#phome').val(),
		        //"fullName": $('#fullName').val()
	    	};
	        table.settings()[0].ajax.data = param;
	        table.ajax.reload();
        });
    });
    
</script>
</body>
</html>
